import { computed } from 'vue';
import { formatServiceTime as FST } from '@/utils';

export default function(orderForm: any, emits: any) {
	
	// 设置上门服务时间
	const setServiceTime = (time: string): void => {
		if (time) orderForm.serviceStartTime = time;
	};
	// 选择上门服务时间
	const chooseServiceTime = (): void => {
		emits('openTime');
	};
	// 格式化上门服务时间
	const formatServiceTime = computed<string>(() => {
		if (orderForm.serviceStartTime) {
			return FST(orderForm.serviceStartTime);
		}
		return '请选择上门时间';
	});
	
	return {
		setServiceTime,
		chooseServiceTime,
		formatServiceTime,
	}
}